<?php

namespace catchAdmin\smstopic\model;


use app\common\model\BaseModel;
use catchAdmin\sms\model\SmsTemplate;
use catchAdmin\smstopic\model\search\SmsTopicSearch;
use catcher\base\CatchModel;

use catcher\base\CatchModel as Model;

/**
 *
 * @property int $id
 * @property string $title
 * @property int $created_at
 * @property int $updated_at
 * @property int $deleted_at
 * @property int $creator_id
 */
class SmsTopic extends CatchModel
{
    use SmsTopicSearch;

    public $field = [
        //
        'id',
        //
        'title',
        'model',
        // 创建时间
        'created_at',
        // 更新时间
        'updated_at',
        // 软删除字段
        'deleted_at',
        // 创建人ID
        'creator_id',
    ];

    public $name = 'smstopic';

    public function children()
    {
        return $this->hasMany(SmsTemplate::class, "sms_topic_id", "id")->field(["id", "title", "content", "sms_topic_id"]);
    }

    /**
     * 获取条件数据
     *
     * @param array $where 条件
     * @param string $field 字段
     * @param string $sortField 排序字段
     * @param string $sort 排序
     * @retrun array
     */
    public function getConditionDatas(array $where=[], string $field="*", string $sortField='created_at', string $sort="desc"): array
    {
        return $this->where($where)->field($field)->order($sortField, $sort)->select()->toArray();
    }

}